package com.report.dto.response;

import cn.zhxu.bs.bean.DbField;
import cn.zhxu.bs.bean.DbIgnore;
import cn.zhxu.bs.bean.SearchBean;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;

import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.List;

/**
 * @author summer
 * @date 2024-06-26 11:44
 */
@Data
@SearchBean(tables = " research_report_file r "+
" LEFT JOIN (SELECT COUNT(*)  AS reportNum,special_id FROM research_special_report GROUP BY special_id ) s ON s.special_id=r.id "+
" LEFT JOIN `report_file_tag` t ON r.id=t.report_file_id ",autoMapTo = "r",groupBy = "r.id" ,orderBy = "r.updateTime DESC")
public class ReportFileRes implements Serializable {

    @DbField("r.id")
    private Integer id;

    @DbField("r.name")
    private String name;

    @DbField("r.image")
    private String image;

    @DbField("r.context")
    private String context;

    @DbField("r.createTime")
    @JsonFormat(pattern = "yyyy-MM-dd",timezone = "GMT+8")
    private LocalDateTime createTime;

    @DbField("r.updateTime")
    @JsonFormat(pattern = "yyyy-MM-dd",timezone = "GMT+8")
    private LocalDateTime updateTime;

    @DbField("GROUP_CONCAT(t.name)")
    private String tagName;

    @DbField("(CASE WHEN s.reportNum IS NULL THEN 0 ELSE s.reportNum END )")
    private Integer reportNum;

    @DbField("r.deleted")
    private Integer deleted;

    @DbIgnore
    private List<Integer> reportIds;

    @DbIgnore
    private Long collectNum;
}
